/*
 * State.cc
 *
 *  Created on: 11 jan. 2011
 *      Author: Frans
 */

#include "State.h"
#include "Direction.h"

State::State(int x, int y) {
	this->coordinate = new Coordinate(x, y);
	this->qValueNorth = 0.0f;
	this->qValueEast = 0.0f;
	this->qValueSouth = 0.0f;
	this->qValueWest = 0.0f;
}

Coordinate * State::getCoordinate() {
	return this->coordinate;
}

int State::getX() {
	return this->getCoordinate()->getX();
}

int State::getY() {
	return this->getCoordinate()->getY();
}

double State::getQValue(int direction) {
	if (direction == 0) {
		return qValueNorth;
	} else if (direction == 1) {
		return qValueEast;
	} else if (direction == 2) {
		return qValueSouth;
	} else {
		return qValueWest;
	}
}

void State::setQValue(int direction, double value) {
	if (direction == 0) {
		qValueNorth = value;
	} else if (direction == 1) {
		qValueEast = value;
	} else if (direction == 2) {
		qValueSouth = value;
	} else {
		qValueWest = value;
	}
}

int State::bestDirection() {
	int result = 0;
	for (int i = 0; i < 4; i++) {
		if (this->getQValue(i) > this->getQValue(result)) {
			result = i;
		}
	}
	return result;
}

double State::getQValueNorth(){
	return qValueNorth;
}
double State::getQValueEast(){
	return qValueEast;
}
double State::getQValueSouth(){
	return qValueSouth;
}
double State::getQValueWest(){
	return qValueWest;
}
